package cn.itcast.web.controller.system;

import cn.itcast.domain.system.SysLog;
import cn.itcast.service.system.SysLogService;
import cn.itcast.web.controller.BaseController;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/system/log")
public class SysLogController extends BaseController{

    @Autowired
    private SysLogService sysLogService;

    /*
        作用：进入日志的列表页面
        路径： /system/sysLog/list.do
        参数： 没有
        返回值： system/sysLog/sysLog-list.jsp
     */
    @RequestMapping("/list")
    public String list(@RequestParam(defaultValue = "1") Integer pageNum,@RequestParam(defaultValue = "5") Integer pageSize
                      ){
        //1. 模拟获取登陆的企业id
        String companyId = getLoginCompanyId();
        //2.  查找到日志
        PageInfo<SysLog> pageInfo = sysLogService.findAll(pageNum, pageSize, companyId);
        //3. 把日志信息存储到域中
        request.setAttribute("pageInfo",pageInfo);
        //4. 返回日志列表
        return "system/log/log-list";
    }

}
